package com.angel.webapp.services.impl;

import com.angel.arquitectura.service.impl.GenericServiceImpl;
import com.angel.arquitectura.service.impl.user.UserServiceImpl;
import com.angel.io.descriptor.ExportFileProcessorDescriptor;
import com.angel.io.descriptor.ExportedFileDescriptor;
import com.angel.io.processors.exports.ExportFileProcessorCommand;
import com.angel.io.processors.exports.ExportRowProcessorCommand;
import com.angel.io.processors.log.ColumnSeparator;
import com.angel.io.processors.runner.impl.ExportFileProcessorRunner;
import com.angel.io.processors.runner.interfaces.ExportProcessorRunner;
import com.angel.webapp.services.ExportFilesService;
import org.apache.log4j.Logger;

import java.util.List;

public class ExportFilesServiceImpl extends GenericServiceImpl implements ExportFilesService {

    private static Logger LOGGER = Logger.getLogger(UserServiceImpl.class);

    public ExportedFileDescriptor doExportFile(List<?> entitiesToExport, ExportFileProcessorCommand fileProcessorCommand, ExportRowProcessorCommand rowProcessorCommand){

        ExportFileProcessorDescriptor descriptor = new ExportFileProcessorDescriptor("User's File", ColumnSeparator.COMMA);

        ExportProcessorRunner processRunner = new ExportFileProcessorRunner(descriptor, rowProcessorCommand, fileProcessorCommand);
		processRunner.addFirstColumn("surname");
		processRunner.addNextColumn("dateBorned");
		processRunner.addNextColumn("userName");
		processRunner.addNextColumn("userPassword");
		processRunner.addNextColumn("name");
		ExportedFileDescriptor exportedFile = processRunner.runProcess(entitiesToExport);

        return exportedFile;
    }

}